//激活快速点击事件，取消手机端的延时
$(function() {
	FastClick.attach(document.body);
});

//tabbar切换效果
$(".tab").each(function(i) {
	$(".tab").eq(i).click(function() {
		$(".tab").removeClass("active");
		$(this).addClass("active");
	})
})

//当前打开的tabbar是哪一个
$(function() {
	//设置默认打开tab
	var type = getUrlItem("type");
	if(type == "") {
		$(".tab").eq(0).click();
	}
	if(type == "jingban") {
		$(".tab").eq(2).click();
	}
	if(type == "duban") {
		$(".tab").eq(1).click();
	}

	var WindowHeight = $(window).height();
	var WindowWidth = $(window).width();
	//给遮罩层设置宽高

	$(".bgBlack").css("height", WindowHeight - 40);
	$(".bgBlack").css("width", WindowWidth);
	$(".supervise-list-searchBar").css("height", WindowHeight - 40);
	$(".supervise-list-searchBar").css("width", WindowWidth * 0.8);
	$(".supervise-list-searchPage").css("height", WindowHeight);
	$(".supervise-list-searchPage").css("width", WindowWidth);

	// 禁止遮罩层的滑动事件
	$('.supervise-list-searchPage').bind("touchmove", function(e) {
		e.preventDefault();
	});
	$('.bgBlack').bind("touchmove", function(e) {
		e.preventDefault();
	});
	$('.supervise-list-searchBar').bind("touchmove", function(e) {
		e.preventDefault();
	});
})

// 点击弹出筛选框
$(".selectBtn").click(function() {
	$(".supervise-list-searchBar").show();
	$(".supervise-list-searchBar").animate({ "right": 0 }, 250);
	setTimeout(function() {
		$(".bgBlack").show();
	}, 150)
})

// 点击关闭遮罩层
$(".bgBlack").click(function() {
	var beClick = $(".supervise-list-tabbar .active>div").eq(1).html(); //判断当前点击的是下方是下方三个tab的哪一个
	switch(beClick) {
		case "全部":
			loadAll(_this);
			break;
		case "我督办":
			loadMyDuBan(_this);
			break;
		case "我经办":
			loadMyJingBan(_this);
			break;
	}
	$(".supervise-list-searchBar").animate({ "right": -600 }, 250);
	setTimeout(function() {
		$(".supervise-list-searchBar").hide();
	}, 250)
	setTimeout(function() {
		$(".bgBlack").hide();
	}, 150)
	_this.searchWrong = false;
})

//搜索框点击
$("#keywords").focus(function() {
	$(".supervise-list-searchPage").show();
	$(".supervise-list-searchPage").animate({ "right": 0 }, 250);
	$(".supervise-list-searchBar").hide();
	$(".bgBlack").hide();
	//	$(".supervise-list-searchPage input").focus();
	$(".supervise-list-search .backBtn").removeClass("vhidden");
})

//搜索框关闭
$(".supervise-list-searchPage .backBtn").click(function() {
	$(".supervise-list-searchPage").animate({ "right": -600 }, 400);
	$(".supervise-list-searchPage").hide();
	$(".supervise-list-searchBar").hide();
	$(".bgBlack").hide();
})

//搜索框返回上一级
$(".supervise-header .backBtn").click(function() {
	$(".supervise-list-searchPage").show();
	$(".supervise-list-searchPage").animate({ "right": 0 }, 400);
	$(".supervise-list-searchBar").hide();
	$(".bgBlack").hide();
})

//筛选功能(部门)
$(".supervise-list-searchBar .department>div").click(function() {
	$(".supervise-list-searchBar .department>div").removeClass("active");
	if($(this).html() == "") {

	} else {
		$(this).addClass("active");
		if($(this).html() == _this.department) {
			$(this).removeClass("active");
			_this.department = "";
		} else {
			_this.department = $(this).html();
		}
	}
})

//筛选功能(工作类型)
$(".supervise-list-searchBar .workType>div").click(function() {
	$(".supervise-list-searchBar .workType>div").removeClass("active");
	if($(this).html() == "") {

	} else {
		$(this).addClass("active");
		if($(this).html() == _this.workType) {
			$(this).removeClass("active");
			_this.workType = "";
		} else {
			_this.workType = $(this).html();
		}
	}
})

//筛选功能（工作状态）
$(".supervise-list-searchBar .workState>div").click(function() {
	$(".supervise-list-searchBar .workState>div").removeClass("active");
	if($(this).html() == "") {

	} else {
		$(this).addClass("active");
		if($(this).html() == _this.workStatus) {
			$(this).removeClass("active");
			_this.workStatus = "";
		} else {
			_this.workStatus = $(this).html();
		}
	}
})

var superviseListVue = new Vue({
	el: "body",
	data: {
		superviseList: [], //存储检索到的任务列表
		keywords: "", //检索的关键词
		workType: "", //筛选功能的条件
		department: "", //筛选功能的条件
		workStatus: "", //筛选功能的条件
		userId: "", //保存用户userId
		searchInfo: "", //保存错误筛选提示信息
		searchWrong: false, //判断是否需要显示错误筛选信息
		userName: "",
		nowPage: 0, //保存当前加载的页数
		loadMore: false, //控制显示加载更多信息
		totalNum: 0, //当前信息总量
		noMore: false, //控制显示已无更多数据信息
		loading: false, //控制在下拉一次未完成之间不再执行下拉
		leaderList: "",
		isLeader: false, //判断是否是馆长
		sumTotal: "" //保存当前所有任务的统计结果
	},
	created: function() {
		_this = this //防止出现闭包
		_this.userId = getUrlItem("userid"); //用户id
		$.cookie("BHCJ_wechat_wechatid", _this.userId, { path: '/', expires: 2 }); //将用户id存在cookie里
		$.ajax({
			type: "get",
			url: "../getinfo.ashx?types=GetUserinfo&userid=" + _this.userId,
			dataType: "json",
			success: function(data) {
				_this.userName = data.name;
				$.cookie("BHCJ_wechat_wechatname", data.name, { path: '/', expires: 2 }); //将用户名存在cookie里
				//保存用户的信息
				$.ajax({
					type: "post",
					url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/SaveUser?callback=?",
					data: {
						"username": _this.userId, //用户id
						"nickname": _this.userName, //用户名
						"phone": data.mobile,
						"imgurl": data.avatar
					},
					dataType: "json",
					success: function(jsondata) {},
					error: function(XMLHttpRequest, textStatus, errorThrown) {}
				});
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {}
		});
		//获取微信权限，并存储到数据库中

		$.getJSON("http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/getHeaderUsers?callback=?", function(jsondata) {
			jsondata.forEach(function(item) {
				_this.leaderList += item.CODE + ","
			})
			_this.leaderList = _this.leaderList.substring(0, _this.leaderList.length - 1)
			_this.leaderList = _this.leaderList.split(",")
			for(var i = 0; i < _this.leaderList.length; i++) {
				if(_this.leaderList[i] == _this.userId) {
					_this.isLeader = true
				}
			}
		});
		//判断当前用户是否是馆长

		$.ajax({
			type: "post",
			url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/GetTaskSum?callback=?",
			data: {},
			dataType: "json",
			success: function(jsondata) {
				_this.sumTotal = jsondata
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {}
		});
		//获取任务数量的统计

		$(document.body).infinite().on("infinite", function() {
			//一页显示10条数据,因此当列表中数据大于等于10时才可以进行下拉刷新
			if(_this.superviseList.length >= 10) {
				//防止多次进行刷新重复操作
				if(_this.loading) return;
				_this.loading = true;
				_this.loadMore = true;
				var beClick = $(".supervise-list-tabbar .active>div").eq(1).html(); //判断当前点击的是下方是下方三个tab的哪一个
				setTimeout(function() {
					var canPage = Math.ceil(_this.totalNum / 10)
					//	当前页大于分页总页则显示已无更多数据
					switch(beClick) {
						case "全部":
							if(canPage > _this.nowPage) {
								loadMoreAll(_this)

							} else {
								_this.noMore = true;
								_this.loadMore = false;
								_this.loading = true;
							}

							break;
						case "我督办":
							if(canPage > _this.nowPage) {
								loadMoreDuBan(_this)
							} else {
								_this.noMore = true;
								_this.loadMore = false;
								_this.loading = true;
							}
							break;
						case "我经办":
							if(canPage > _this.nowPage) {
								loadMoreJingBan(_this)
							} else {
								_this.noMore = true;
								_this.loadMore = false;
								_this.loading = true;
							}
							break;
					};
				}, 2000);
			} else {
				if(_this.superviseList.length == 0) {

				} else {
					_this.noMore = true
				}
			}
		});
		//		下拉刷新时间设置

	},
	methods: {
		detail: function(id) {
			location.href = "superviseDetail.html?TASKID=" + id + "&userid=" + _this.userId
		}, //查看详情
		allList: function() {
			loadAll(_this)
		}, //加载全部任务列表
		dubanList: function() {
			loadMyDuBan(_this)
		}, //加载我督办列表
		jingbanList: function() {
			loadMyJingBan(_this)
		}, //加载我经办列表
		selectList: function() {
			loadSelectList(_this)
		}, //筛选出的任务列表
		restSelect: function() {
			loadRestSelect(_this)
		}, //重置筛选返回默认
		setLike: function(a, b, c) {
			clickLike(a, b, _this, c)
		},
		selectKeywords: function() {
			loadSelectKeywords(_this)
		},
		restKeywords: function() {
			clearKeywords(_this)
		}
	}
})

//加载全部任务
function loadAll(a) {
	a.superviseList = [] //切换tab前先清空列表数据防止残留数据触发加载更多操作
	a.nowPage = 1;
	a.noMore = false;
	a.loading = false;
	a.loadMore = false;
	$(".supervise-body").addClass("hidden")
	$(".supervise-list-tabbar").addClass("hidden")
	$(".loader").removeClass("hidden")
	$.ajax({
		type: "post",
		url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/getTaskList?callback=?",
		data: {
			"pagesize": 10,
			"pageno": a.nowPage,
			"man": a.userId,
			"type": "all",
			"keyword": a.keywords,
			"department": a.department,
			"worktype": a.workType,
			"year":"",
			"workstatus": a.workStatus,
			"exworkstatus": "结束"
		},
		dataType: "json",
		success: function(jsondata) {
			console.log(jsondata)
			a.sumTotal = jsondata.total_num
			a.totalNum = jsondata.total_count
			jsondata.data.forEach(function(item) {
				if(item.LIKES != null) {
					item.ISLIKE = false;
					item.LIKENUM = item.LIKES.length
					item.LIKEMANLIST = ""
					item.LIKES.forEach(function(like) {
						item.LIKEMANLIST += like.LIKEMANNAME + ","
						if(like.LIKEMANID == a.userId) {
							item.ISLIKE = true
						}
					})
					item.LIKEMANLIST = item.LIKEMANLIST.substring(0, item.LIKEMANLIST.length - 1)
				} else {
					item.ISLIKE = false;
					item.LIKENUM = 0;
					item.LIKEMANLIST = null;

				}
			});
			//对返回的数据进行是否点赞操作

			jsondata.data.forEach(function(item) {
				if(item.BEGINDATE != null) {
					item.BEGINDATE = item.BEGINDATE.replace(/-/g, "/");
				}
				if(item.ENDDATE != null) {
					item.ENDDATE = item.ENDDATE.replace(/-/g, "/");
				}
			});
			//对返回到数据进行时间格式整理操作

			_this.superviseList = jsondata.data;
			_this.$nextTick(function() {
				setTimeout(function() {
					$(".supervise-body").removeClass("hidden")
					$(".supervise-list-tabbar").removeClass("hidden")
					$(".loader").addClass("hidden")
				}, 200)
			})
		}
	});
}

//记载我督办函数
function loadMyDuBan(a) {
	a.superviseList = [] //切换tab前先清空列表数据防止残留数据触发加载更多操作
	a.nowPage = 1;
	a.noMore = false;
	a.loading = false;
	a.loadMore = false;
	$(".supervise-body").addClass("hidden")
	$(".supervise-list-tabbar").addClass("hidden")
	$(".loader").removeClass("hidden")
	$.ajax({
		type: "post",
		url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/getTaskList?callback=?",
		data: {
			"pagesize": 10,
			"pageno": a.nowPage,
			"man": a.userId,
			"type": "duban",
			"keyword": a.keywords,
			"department": a.department,
			"worktype": a.workType,
			"year":"",
			"workstatus": a.workStatus,
			"exworkstatus": "结束"
		},
		dataType: "json",
		success: function(jsondata) {
			a.totalNum = jsondata.total_count;
			a.sumTotal = jsondata.total_num;
			jsondata.data.forEach(function(item) {
				if(item.LIKES != null) {
					item.ISLIKE = false;
					item.LIKENUM = item.LIKES.length
					item.LIKEMANLIST = ""
					item.LIKES.forEach(function(like) {
						item.LIKEMANLIST += like.LIKEMANNAME + ","
						if(like.LIKEMANID == a.userId) {
							item.ISLIKE = true
						}
						item.LIKEMANLIST = item.LIKEMANLIST.substring(0, item.LIKEMANLIST.length - 1)
					})
				} else {
					item.ISLIKE = false;
					item.LIKENUM = 0;
					item.LIKEMANLIST = null;
				}
			});

			//对返回的数据进行是否点赞操作

			jsondata.data.forEach(function(item) {
				if(item.BEGINDATE != null) {
					item.BEGINDATE = item.BEGINDATE.replace(/-/g, "/");
				}
				if(item.ENDDATE != null) {
					item.ENDDATE = item.ENDDATE.replace(/-/g, "/");
				}
			});
			//对返回到数据进行时间格式整理操作

			_this.superviseList = jsondata.data;
			_this.$nextTick(function() {
				setTimeout(function() {
					$(".supervise-body").removeClass("hidden")
					$(".supervise-list-tabbar").removeClass("hidden")
					$(".loader").addClass("hidden")
				}, 200)
			})
		}
	});
}

//加载我经办函数
function loadMyJingBan(a) {
	a.superviseList = [] //切换tab前先清空列表数据防止残留数据触发加载更多操作
	a.nowPage = 1;
	a.noMore = false;
	a.loading = false;
	a.loadMore = false;
	$(".supervise-body").addClass("hidden")
	$(".supervise-list-tabbar").addClass("hidden")
	$(".loader").removeClass("hidden")
	$.ajax({
		type: "post",
		url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/getTaskList?callback=?",
		data: {
			"pagesize": 10,
			"pageno": a.nowPage,
			"man": a.userId,
			"type": "jingban",
			"keyword": a.keywords,
			"department": a.department,
			"worktype": a.workType,
			"year":"",
			"workstatus": a.workStatus,
			"exworkstatus": "结束"
		},
		dataType: "json",
		success: function(jsondata) {
			a.sumTotal = jsondata.total_num;
			a.totalNum = jsondata.total_count;
			jsondata.data.forEach(function(item) {
				if(item.LIKES != null) {
					item.ISLIKE = false;
					item.LIKENUM = item.LIKES.length
					item.LIKEMANLIST = ""
					item.LIKES.forEach(function(like) {
						item.LIKEMANLIST += like.LIKEMANNAME + ","
						if(like.LIKEMANID == a.userId) {
							item.ISLIKE = true
						}
					})
					item.LIKEMANLIST = item.LIKEMANLIST.substring(0, item.LIKEMANLIST.length - 1)
				} else {
					item.ISLIKE = false;
					item.LIKENUM = 0;
					item.LIKEMANLIST = null;
				}
			});

			//对返回的数据进行是否点赞操作
			jsondata.data.forEach(function(item) {
				if(item.BEGINDATE != null) {
					item.BEGINDATE = item.BEGINDATE.replace(/-/g, "/");
				}
				if(item.ENDDATE != null) {
					item.ENDDATE = item.ENDDATE.replace(/-/g, "/");
				}
			});
			//对返回到数据进行时间格式整理操作

			_this.superviseList = jsondata.data;
			_this.$nextTick(function() {
				setTimeout(function() {
					$(".supervise-body").removeClass("hidden")
					$(".supervise-list-tabbar").removeClass("hidden")
					$(".loader").addClass("hidden")
				}, 200)
			})
			//loading图
		}
	});
}

//对筛选框数据的条件进行验证
function loadSelectList(a) {
	var beClick = $(".supervise-list-tabbar .active>div").eq(1).html(); //判断当前点击的是下方是下方三个tab的哪一个
	if(a.department == "" && a.workType == "" && a.workStatus == "") {
		a.searchInfo = "请至少选填一项。";
		a.searchWrong = true;
	} else {
		a.searchInfo = "";
		a.searchWrong = false;
		switch(beClick) {
			case "全部":
				loadAll(a)
				break;
			case "我督办":
				loadMyDuBan(a)
				break;
			case "我经办":
				loadMyJingBan(a)
				break;
		}
		$(".bgBlack").click()
	}
}

//清除侧边筛选框筛选条件
function loadRestSelect(a) {
	var beClick = $(".supervise-list-tabbar .active>div").eq(1).html(); //判断当前点击的是下方是下方三个tab的哪一个
	a.workType = "";
	a.department = "";
	a.workStatus = "";
	$(".supervise-list-searchBar .workType>div").removeClass("active");
	$(".supervise-list-searchBar .department>div").removeClass("active")
	switch(beClick) {
		case "全部":
			loadAll(a)
			break;
		case "我督办":
			loadMyDuBan(a)
			break;
		case "我经办":
			loadMyJingBan(a)
			break;
	};
	$(".bgBlack").click()
}

//侧边筛选框筛选函数
function loadSelectKeywords(a) {
	$(".supervise-list-searchPage").animate({ "right": -600 }, 250);
	$(".supervise-list-searchPage").hide();
	$(".supervise-list-searchBar").hide();
	$(".bgBlack").hide();
	$(".supervise-list-search .backBtn").removeClass("vhidden")
	var beClick = $(".supervise-list-tabbar .active>div").eq(1).html(); //判断当前点击的是下方是下方三个tab的哪一个
	switch(beClick) {
		case "全部":
			loadAll(a)
			break;
		case "我督办":
			loadMyDuBan(a)
			break;
		case "我经办":
			loadMyJingBan(a)
			break;
	};
}

//清除搜索框输入条件
function clearKeywords(a) {
	a.keywords = "";
	var beClick = $(".supervise-list-tabbar .active>div").eq(1).html(); //判断当前点击的是下方是下方三个tab的哪一个
	$(".supervise-list-searchPage .backBtn").click()
	$(".supervise-list-search .backBtn").addClass("vhidden")
	switch(beClick) {
		case "全部":
			loadAll(a)
			break;
		case "我督办":
			loadMyDuBan(a)
			break;
		case "我经办":
			loadMyJingBan(a)
			break;
	};
}

//点赞函数
function clickLike(index, id, obj, taskName) {
	$.ajax({
		type: "post",
		url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/clickLike?callback=?",
		data: {
			"taskcode": id,
			"manid": obj.userId,
			"manname": obj.userName,
		},
		dataType: "json",
		success: function(data) {
			var useridArry;
			if(data.taskManIdList != "" && data.dubanManIdList != "") {
				useridArry = data.taskManIdList + "," + data.dubanManIdList
			} else {
				if(data.taskManIdList == "") {
					useridArry = data.dubanManIdList
				};
				if(data.dubanManIdList == "") {
					useridArry = data.taskManIdList
				}
			};
			var set_loastr = "";
			var set_loc = "";
			if(useridArry.indexOf(",")) {
				$.each(useridArry.split(','), function(index, item) {
					item = item.split('=');
					var name = item[0];
					set_loastr = name + "|";
					set_loc += set_loastr;
				});
				set_loc = set_loc.substring(0, set_loc.length - 1);
				set_loc = set_loc;
			} else {
				set_loc = useridArry;
			}
			sendLikeMsg(set_loc, _this.userName, taskName)
			obj.superviseList[index].ISLIKE = true;
			obj.superviseList[index].LIKENUM++;
			if(obj.superviseList[index].LIKEMANLIST != null) {
				obj.superviseList[index].LIKEMANLIST += "," + _this.userName
			} else {
				obj.superviseList[index].LIKEMANLIST = _this.userName
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert(JSON.stringify(XMLHttpRequest));
			alert(textStatus);
			alert(errorThrown);
		}
	});
}

//从url中截取传递到数据
function getUrlItem(name) { //id
	var url = location.search
	start = url.indexOf(name + "=")
	if(start != -1) {
		start = start + name.length + 1
		end = url.indexOf("&", start)
		if(end == -1) {
			end = url.length
			return unescape(url.substring(start, end))
		}
		return unescape(url.substring(start, end))
	}
	return '';
}

//点赞之后给经办人督办人发送消息
function sendLikeMsg(sendList, userName, taskTitle) {
	$.ajax({
		type: "POST",
		crossDomain: true,
		url: "../getinfo.ashx?types=send&userlist=",
		dataType: "json",
		data: {
			Ulist: sendList,
			context: "任务【" + taskTitle + "】得到了【" + userName + "】的鼓励",
			pageUrl: ""
		},
		success: function(jsondata) {},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert(JSON.stringify(XMLHttpRequest));
			alert(textStatus);
			alert(errorThrown);
		}
	});

}

//全部下拉加载更多
function loadMoreAll(a) {
	a.nowPage++;
	$.ajax({
		type: "post",
		url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/getTaskList?callback=?",
		data: {
			"pagesize": 10,
			"pageno": a.nowPage,
			"man": a.userId,
			"type": "all",
			"keyword": a.keywords,
			"department": a.department,
			"worktype": a.workType,
			"year":"",
			"workstatus": a.workStatus,
			"exworkstatus": "结束"
		},
		dataType: "json",
		success: function(jsondata) {
			console.log(jsondata)
			jsondata.data.forEach(function(item) {
				if(item.LIKES != null) {
					item.ISLIKE = false;
					item.LIKENUM = item.LIKES.length
					item.LIKEMANLIST = ""
					item.LIKES.forEach(function(like) {
						item.LIKEMANLIST += like.LIKEMANNAME + ","
						if(like.LIKEMANID == a.userId) {
							item.ISLIKE = true
						}
					})
					item.LIKEMANLIST = item.LIKEMANLIST.substring(0, item.LIKEMANLIST.length - 1)

				} else {
					item.ISLIKE = false;
					item.LIKENUM = 0;
					item.LIKEMANLIST = null;
				}
			});
			//对返回的数据进行是否点赞操作

			jsondata.data.forEach(function(item) {
				if(item.BEGINDATE != null) {
					item.BEGINDATE = item.BEGINDATE.replace(/-/g, "/");
				}
				if(item.ENDDATE != null) {
					item.ENDDATE = item.ENDDATE.replace(/-/g, "/");
				}
			});

			//			对返回到数据进行时间格式整理操作
			for(var i = 0; i < jsondata.data.length; i++) {
				a.superviseList.push(jsondata.data[i]);
			}
			a.loadMore = false;
			a.loading = false;
		}
	});
}

//我督办下拉加载更多
function loadMoreDuBan(a) {
	a.nowPage++;
	$.ajax({
		type: "post",
		url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/getTaskList?callback=?",
		data: {
			"pagesize": 10,
			"pageno": a.nowPage,
			"man": a.userId,
			"type": "duban",
			"keyword": a.keywords,
			"department": a.department,
			"worktype": a.workType,
			"year":"",
			"workstatus": a.workStatus,
			"exworkstatus": "结束"
		},
		dataType: "json",
		success: function(jsondata) {
			console.log(jsondata.total_count)
			jsondata.data.forEach(function(item) {
				if(item.LIKES != null) {
					item.ISLIKE = false;
					item.LIKENUM = item.LIKES.length
					item.LIKEMANLIST = ""
					item.LIKES.forEach(function(like) {
						item.LIKEMANLIST += like.LIKEMANNAME + ","
						if(like.LIKEMANID == a.userId) {
							item.ISLIKE = true
						}
					})
					item.LIKEMANLIST = item.LIKEMANLIST.substring(0, item.LIKEMANLIST.length - 1)
				} else {
					item.ISLIKE = false;
					item.LIKENUM = 0;
					item.LIKEMANLIST = null;
				}
			});
			//对返回的数据进行是否点赞操作

			jsondata.data.forEach(function(item) {
				if(item.BEGINDATE != null) {
					item.BEGINDATE = item.BEGINDATE.replace(/-/g, "/");
				}
				if(item.ENDDATE != null) {
					item.ENDDATE = item.ENDDATE.replace(/-/g, "/");
				}
			});
			//			对返回到数据进行时间格式整理操作
			for(var i = 0; i < jsondata.data.length; i++) {
				a.superviseList.push(jsondata.data[i]);
			}
			a.loadMore = false;
			a.loading = false;

		}
	});
}

//我经办下拉加载更多
function loadMoreJingBan(a) {
	a.nowPage++;
	$.ajax({
		type: "post",
		url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/getTaskList?callback=?",
		data: {
			"pagesize": 10,
			"pageno": a.nowPage,
			"man": a.userId,
			"type": "jingban",
			"keyword": a.keywords,
			"department": a.department,
			"worktype": a.workType,
			"year":"",
			"workstatus": a.workStatus,
			"exworkstatus": "结束"
		},
		dataType: "json",
		success: function(jsondata) {
			console.log(jsondata.total_count)
			jsondata.data.forEach(function(item) {
				if(item.LIKES != null) {
					item.ISLIKE = false;
					item.LIKENUM = item.LIKES.length
					item.LIKEMANLIST = ""
					item.LIKES.forEach(function(like) {
						item.LIKEMANLIST += like.LIKEMANNAME + ","
						if(like.LIKEMANID == a.userId) {
							item.ISLIKE = true
						}
					})
					item.LIKEMANLIST = item.LIKEMANLIST.substring(0, item.LIKEMANLIST.length - 1)
				} else {
					item.ISLIKE = false;
					item.LIKENUM = 0;
					item.LIKEMANLIST = null;
				}
			});
			//对返回的数据进行是否点赞操作

			jsondata.data.forEach(function(item) {
				if(item.BEGINDATE != null) {
					item.BEGINDATE = item.BEGINDATE.replace(/-/g, "/");
				}
				if(item.ENDDATE != null) {
					item.ENDDATE = item.ENDDATE.replace(/-/g, "/");
				}
			});
			//			对返回到数据进行时间格式整理操作
			for(var i = 0; i < jsondata.data.length; i++) {
				a.superviseList.push(jsondata.data[i]);
			}
			a.loadMore = false;
			a.loading = false;
		}
	});
}